package com.container;

import java.util.List;




import com.activity.R;
import com.container.ListaCompra.Element;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListaCompraAdapter extends BaseAdapter {

	private Context mContext;
	private ListaCompra lc;
	
	
	public ListaCompraAdapter(Context mContext, ListaCompra lc) {
		this.mContext = mContext;
		this.lc = lc;
	}

	public int getCount() {
		return lc.size();
	}

	public Element getItem(int position) {
		return lc.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		Element elem = lc.get(position);
		
		View v = View.inflate(mContext, R.layout.row_libro, null);

		TextView nom = (TextView) v.findViewById(R.id.libro_nombre);
		TextView aut = (TextView) v.findViewById(R.id.libro_autor);
		TextView prec = (TextView) v.findViewById(R.id.libro_precio);
		
		nom.setText(elem.libro.getNombre() +  "  [ " + String.valueOf(elem.cantidad) +" unidad(es) ]");
		aut.setText("Autor: " + elem.libro.getAutor());
		prec.setText("Precio: " + String.valueOf(elem.libro.getPrecio()));
		
		return v;
	}

}